home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / email / mime / image.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.0 KB  |  45 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Class representing image/* type MIME documents.'''
  5. __all__ = [
  6.     'MIMEImage']
  7. import imghdr
  8. from email import encoders
  9. from email.mime.nonmultipart import MIMENonMultipart
  10.  
  11. class MIMEImage(MIMENonMultipart):
  12.     '''Class for generating image/* type MIME documents.'''
  13.     
  14.     def __init__(self, _imagedata, _subtype = None, _encoder = encoders.encode_base64, **_params):
  15.         """Create an image/* type MIME document.
  16.  
  17.         _imagedata is a string containing the raw image data.  If this data
  18.         can be decoded by the standard Python `imghdr' module, then the
  19.         subtype will be automatically included in the Content-Type header.
  20.         Otherwise, you can specify the specific image subtype via the _subtype
  21.         parameter.
  22.  
  23.         _encoder is a function which will perform the actual encoding for
  24.         transport of the image data.  It takes one argument, which is this
  25.         Image instance.  It should use get_payload() and set_payload() to
  26.         change the payload to the encoded form.  It should also add any
  27.         Content-Transfer-Encoding or other headers to the message as
  28.         necessary.  The default encoding is Base64.
  29.  
  30.         Any additional keyword arguments are passed to the base class
  31.         constructor, which turns them into parameters on the Content-Type
  32.         header.
  33.         """
  34.         if _subtype is None:
  35.             _subtype = imghdr.what(None, _imagedata)
  36.         
  37.         if _subtype is None:
  38.             raise TypeError('Could not guess image MIME subtype')
  39.         _subtype is None
  40.         MIMENonMultipart.__init__(self, 'image', _subtype, **_params)
  41.         self.set_payload(_imagedata)
  42.         _encoder(self)
  43.  
  44.  
  45.